﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Gmantis.Controls
{
    public class ScrollViewerCornerRadiusBuilder : ScrollViewerCornerRadiusBase
    {
        // Fields
        private CornerRadius? _output = null;
        public static readonly DependencyProperty OrientationProperty;

        // Methods
        static ScrollViewerCornerRadiusBuilder()
        {
            OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(ScrollViewerCornerRadiusBuilder), new PropertyMetadata(Orientation.Vertical, (d, a) => (d as ScrollViewerCornerRadiusBuilder).UpdateOutput()));
        }

        protected override void UpdateOutput()
        {
            this._output = null;
            base.RaisePropertyChanged("Output");
        }

        // Properties
        public Orientation Orientation
        {
            get
            {
                return (Orientation)base.GetValue(OrientationProperty);
            }
            set
            {
                base.SetValue(OrientationProperty, value);
            }
        }

        public CornerRadius Output
        {
            get
            {
                if (!this._output.HasValue)
                {
                    if (this.Orientation == Orientation.Vertical)
                    {
                        this._output = new CornerRadius(0.0, base.CornerRadius.TopRight, (base.HorizontalScrollBarVisibility == Visibility.Visible) ? 0.0 : base.CornerRadius.BottomRight, 0.0);
                    }
                    else
                    {
                        this._output = new CornerRadius(0.0, 0.0, (base.VerticalScrollBarVisibility == Visibility.Visible) ? 0.0 : base.CornerRadius.BottomRight, base.CornerRadius.BottomLeft);
                    }
                }
                return this._output.Value;
            }
        }
    }
}
